package com.crazy.common.filter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.springframework.orm.hibernate4.support.OpenSessionInViewFilter;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;
/**
 * hibernate4 OpenSessionInViewFilter静态资源过滤器，控制静态资源访问不打开session
 * @author Zhang Weiwei
 * @since 2013-11-2下午5:54:02
 */
public class MyOpenSessionInViewFilter extends OpenSessionInViewFilter {
	private static PathMatcher matcher = new AntPathMatcher();
	private static final String pattern = "/**/*.*";
	@Override
	protected boolean shouldNotFilter(HttpServletRequest request)
			throws ServletException {
		String path = request.getServletPath();
		boolean result = matcher.match(pattern, path)
				|| matcher.match("/validCode*", path);
		return result;
	}
}
